<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/html/init.jsp"%>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui"%>

<portlet:actionURL var="showSubjectByFacultyURL">
	<portlet:param name="action" value="showSubjectByFaculty" />
</portlet:actionURL>

<portlet:actionURL var="deleteCheckedSubjectByIdURL">
	<portlet:param name="action" value="deleteCheckedSubjectById" />
</portlet:actionURL>

<portlet:renderURL var="showPageInsertNewSubjectByFacultyURL">
	<portlet:param name="action" value="showPageInsertNewSubjectByFaculty" />
</portlet:renderURL>

<portlet:actionURL var="viewPageSubjectByFacultyURL">
	<portlet:param name="action" value="viewPageSubjectByFaculty" />
</portlet:actionURL>

<liferay-ui:success key="success" message="Cập nhật thành công" />
<liferay-ui:error key="fail" message="Cập nhật thất bại" />

<form action="${showSubjectByFacultyURL}" method="post">
	<select name='<portlet:namespace/>idFaculty'>
		<option>Khoa</option>
		<c:forEach items="${listFaculty}" var="e">
			<option value="${e.idFaculty}"
				<c:if test="${idFaculty==e.idFaculty}">selected="selected"</c:if>>${e.nameFaculty}</option>
		</c:forEach>
	</select>
	<button class="btn-success" type="submit">Create</button>
</form>
<a href="${showPageInsertNewSubjectByFacultyURL}">Create new Subject</a>

<c:if test="${not empty listSubject}">
	<table class="table table-striped table-hover">
		<thead>
			<tr>
				<td>Mã môn</td>
				<td>Tên môn</td>
				<td>Số tín chỉ</td>
				<td>Tuỳ chỉnh</td>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${listSubject}" var="f">
				<tr>
					<td>${f.idSubject}</td>
					<td>${f.nameSubject}</td>
					<td>${f.numberOfCredit}</td>
					<td>
						<form action="${viewPageSubjectByFacultyURL}" method="post">
							<input type="hidden" value="${f.idSubject}"
								name='<portlet:namespace/>idSubject' /> <button type="submit" class="btn-info"
								>Chỉnh sửa</button>
						</form>
						<form action="${deleteCheckedSubjectByIdURL}" method="post">
							<input type="hidden" value="${f.idSubject}"
								name='<portlet:namespace/>idSubject' /> <button type="submit"
								class="btn-danger">Xoá</button>
						</form>
					</td>
				</tr>
			</c:forEach>
		</tbody>
	</table>


	<form action="${showPageInsertNewSubjectURL}" method="post">
		<c:forEach items="${listSemester}" var="e">
			<button class="btn-success" type="submit">Create Subject
				Open</button>
		</c:forEach>
	</form>
</c:if>